home *** CD-ROM | disk | FTP | other *** search
- // ===========================================================================
- // CAppearanceApp.cp ©1994-1999 Metrowerks Inc. All rights reserved.
- // ===========================================================================
- // This file contains the starter code for a basic PowerPlant project
-
- #include "CAppearanceApp.h"
-
- #include <LGrowZone.h>
- #include <PP_Messages.h>
- #include <PP_Resources.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <URegistrar.h>
- #include <UEnvironment.h>
-
- #include <UControlRegistry.h>
-
- #include <LWindow.h>
-
- #include <Appearance.h>
- #include "CSemaphorePicture.h"
-
-
- // Constant declarations
- const ResIDT PPob_MainWindow = 128;
- const PaneIDT Pane_Picture = 1;
-
- // ===========================================================================
- // • main
- // ===========================================================================
-
- int main()
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Alert);
-
- // Initialize Memory Manager. Parameter is the number of
- // master pointer blocks to allocate
- InitializeHeap(3);
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- // Install a GrowZone to catch low-memory situations
- new LGrowZone(20000);
-
- // Create the application object and run
- CAppearanceApp theApp;
- theApp.Run();
-
- return 0;
- }
-
-
- // ---------------------------------------------------------------------------
- // • CAppearanceApp [public]
- // ---------------------------------------------------------------------------
- // Application object constructor
-
- CAppearanceApp::CAppearanceApp()
- {
- // Register ourselves with the Appearance Manager
- if (UEnvironment::HasFeature(env_HasAppearance)) {
- ::RegisterAppearanceClient();
- }
-
- RegisterClasses();
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CAppearanceApp [public, virtual]
- // ---------------------------------------------------------------------------
- // Application object destructor
-
- CAppearanceApp::~CAppearanceApp()
- {
- // Nothing
- }
-
-
- // ---------------------------------------------------------------------------
- // • StartUp [protected, virtual]
- // ---------------------------------------------------------------------------
- // Perform an action in response to the Open Application AppleEvent.
- // Here, issue the New command to open a window.
-
- void
- CAppearanceApp::StartUp()
- {
- ObeyCommand(cmd_New, nil);
- }
-
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand [public, virtual]
- // ---------------------------------------------------------------------------
- // Respond to Commands. Returns true if the Command was handled, false if not.
-
- Boolean
- CAppearanceApp::ObeyCommand(
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = true; // Assume we'll handle the command
-
- switch (inCommand) {
-
- case cmd_New: {
- LWindow* theWindow = LWindow::CreateWindow(PPob_MainWindow, this);
- ThrowIfNil_(theWindow);
-
- // attach app as listener
- CSemaphorePicture* picture = dynamic_cast<CSemaphorePicture*> (theWindow->FindPaneByID(Pane_Picture));
- ThrowIfNil_(picture);
- theWindow->SetLatentSub(picture);
-
- theWindow->Show();
- break;
- }
-
- default: {
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus [public, virtual]
- // ---------------------------------------------------------------------------
- // Determine the status of a Command for the purposes of menu updating.
-
- void
- CAppearanceApp::FindCommandStatus(
- CommandT inCommand,
- Boolean& outEnabled,
- Boolean& outUsesMark,
- UInt16& outMark,
- Str255 outName)
- {
- switch (inCommand) {
-
- case cmd_New: {
- outEnabled = true;
- break;
- }
-
- default: {
- LApplication::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • RegisterClasses [protected]
- // ---------------------------------------------------------------------------
- // To reduce clutter within the Application object's constructor, class
- // registrations appear here in this seperate function for ease of use.
-
- void
- CAppearanceApp::RegisterClasses()
- {
- // Register core PowerPlant classes.
- RegisterClass_(LWindow);
-
- // Register the Appearance Manager/GA classes. You may want
- // to remove this use of UControlRegistry and instead perform
- // a "manual" registration of the classes. This cuts down on
- // extra code being linked in and streamlines your app and
- // project. However, use UControlRegistry as a reference/index
- // for your work, and ensure to check UControlRegistry against
- // your registrations each PowerPlant release in case
- // any mappings might have changed.
-
- UControlRegistry::RegisterClasses();
-
- // Register my class
- RegisterClass_(CSemaphorePicture);
- }